Uec3.HireHistoryWindow = Ext.extend(Ext.app.Module, {
	id : 'hireHistory',
	type : 'common/hireHistory',

	/**
	 * Initialize this module. This function is called at startup (page
	 * load/refresh).
	 */
	init : function(initParams) {

	},
	paramsCollection : new Ext.util.MixedCollection(true),

	getParamsByKey : function(key) {

		return this.paramsCollection.get(key);
	},

	getComponents : function(params) {

		var hireHistory_ds;
		var hireHistory_grid;

		var getAndRestoreHistory = function() {

			var id = 0;

			if (params && params.id) {

				id = params.id;

			}

			hireHistory_ds = new Ext.data.Store({

				proxy : new Ext.data.HttpProxy({
					url : Uec3.App.Constants.homeUrl
							+ '/employee/browse_HireHistory!browseHireHistory.do'
				}),
				baseParams : {
					start : 0,
					limit : 20,
					id : id
				},
				reader : new Ext.data.JsonReader({
							totalProperty : 'totalProperty',
							root : 'root'
						}, [{
									name : 'id'
								}, {
									name : 'userName'
								}, {
									name : 'companyName'
								},

								{
									name : 'typeName'
								},

								{
									name : 'evaluation'
								}, {
									name : 'gmtCreate',
									type : 'string'
								}

						]),

				remoteSort : true,

				// 默认排序字段
				sortInfo : {
					field : "id",
					direction : "asc"
				}

			});

		};

		var componentInitsHistory = function() {
			// 初始化historyAddress表格对象

			var history_colModel = new Ext.grid.ColumnModel([
					new Ext.grid.RowNumberer(),
{
						header : "用户名称",
						width : 80,
						sortable : true,
						dataIndex : 'userName'
					},

					{
						header : "公司名称",
						width : 80,
						sortable : true,
						dataIndex : 'companyName'
					}, {
						header : "工作状态",
						width : 80,
						sortable : true,
						dataIndex : 'typeName'
					}, {
						header : "创建时间",
						width : 100,
						sortable : true,
						dataIndex : 'gmtCreate'
					}, {
						header : "员工评价",
						width : 160,
						sortable : true,
						dataIndex : 'evaluation'
					}

			]);

			// create the Grid
			hireHistory_grid = new Ext.grid.GridPanel(

			{
						// title:'部门信息列表',
						region : 'center',
						iconCls : 'icon-grid',
						enableColumnMove : false,
						enableColumnMoveResize : false,
						stripeRows : true,
						height : 500,
						loadMask : {
							msg : "...加载数据中"
						},
						store : hireHistory_ds,
						cm : history_colModel,
						sm : new Ext.grid.RowSelectionModel({
									singleSelect : true
								}),
						viewConfig : {
							forceFit : true,
							columnsText : '显示的列',
							scrollOffset : 20,
							sortAscText : '升序',
							sortDescText : '降序'
						},
						bbar : new Ext.PagingToolbar({
									pageSize : 20,
									store : hireHistory_ds,
									display : true,
									displayMsg : '第 {0} - {1} 条  共 {2} 条',
									emptyMsg : "没有记录",
									displayInfo : true,
									items : [/**
												 * '-', { pressed: true,
												 * enableToggle:true, text:
												 * 'Show Preview', cls:
												 * 'x-btn-text-icon details',
												 * toggleHandler: function(btn,
												 * pressed){ var view =
												 * hireHistory_grid.getView();
												 * view.showPreview = pressed;
												 * view.refresh(); } }
												 */
									]
								})

					});

			if (params && params.id) {

				hireHistory_ds.load();

			}
		};

		var controlHistoryEvent = function() {
		};
		
		
		getAndRestoreHistory();

		componentInitsHistory();

		controlHistoryEvent();
		this.paramsCollection.add("hireHistory_ds", hireHistory_ds);
		return hireHistory_grid;

	},
	initEvent:function(){
		var module=this;
		var win=module.getParamsByKey("win");
		win.on('show',function(){
			this.getParamsByKey("hireHistory_ds").load({
				 callback: function(records,options,success){
		         
		         if(success){
		        	 
		        	// Ext.Msg.alert('提示',"加载数据成功");
		         }else{
		        	 
		        	 
		        	 Ext.Msg.alert('提示',"网络连接异常...请稍候再试");
		         }			  
			
		 }			
	
	});
		},module,{single:true});
	},
	/**
	 * Create this modules window here.
	 */
	createWindow : function(params) {

		var windowId = 'hireHistory';
		if (params) {
			windowId += "_" + params.winId;
		}
		var module = this;
		var desktop = this.app.getDesktop();
		var win = desktop.getWindow(windowId);
		if (!win) {
			win = desktop.createWindow({
						id : windowId,
						title : '员工雇佣列表',
						width : document.body.clientWidth * 0.9,
						height : document.body.clientHeight * 0.9,
						iconCls : 'acc-icon',
						shim : false,
						autoScroll : true,
						animCollapse : false,
						constrainHeader : true,
						maximizable : true,
						taskbuttonTooltip : "员工雇佣列表",
						layout : "fit",
						listeners : {
							'resize' : function(win, width, height) {
								if (width < 800 || height < 500) {
									win.setWidth(800);
									win.setHeight(500);
									this.items.get(0).setHeight(500);
								} else {
									this.items.get(0).setHeight(height);
								}
							}
						},
						tools : [{
									id : 'refresh',
									handler : Ext.emptyFn,
									scope : this
								}],
						items : [this.getComponents(params)]
					});
			module.paramsCollection.add("win",win);
			module.initEvent();

		}
		win.show();

	}
});